from docx import Document
from pptx import Presentation

def add_word_to_ppt_notes(word_file, ppt_file):
    doc = Document(word_file)
    prs = Presentation(ppt_file)

    current_slide_index = 0

    for paragraph in doc.paragraphs:
        if paragraph.style.name.startswith('Heading 1'):
            if current_slide_index < len(prs.slides):
                add_content_to_slide(paragraph.text, prs.slides[current_slide_index])
                current_slide_index += 1
        else:
            if current_slide_index < len(prs.slides):
                append_content_to_slide(paragraph.text, prs.slides[current_slide_index])

    prs.save('output2.pptx')

def add_content_to_slide(title, slide):
    notes_slide = slide.notes_slide
    notes_shape = notes_slide.notes_text_frame

    notes_shape.text = title

def append_content_to_slide(content, slide):
    notes_slide = slide.notes_slide
    notes_shape = notes_slide.notes_text_frame

    if notes_shape.text:
        notes_shape.text += '\n' + content
    else:
        notes_shape.text = content

if __name__ == '__main__':
    add_word_to_ppt_notes('人工智能.docx', '人工智能.pptx')
